package ldh.im.dto.business;

import ldh.im.dto.base.Req;

import java.io.File;

public class TransferFile extends Req {

    private Long userId;
    private String messageId;
    private String mid;
    private String fileName;
    private String path;
    private Long size;

    public TransferFile() {
//        register();
    }

    public TransferFile(Long userId, String mId, String path) {
        this.userId = userId;
        this.mid = mId;
        this.path = path;
        calcFileName();

//        register();
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getMid() {
        return mid;
    }

    public void setMid(String mid) {
        this.mid = mid;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    private void calcFileName() {
        int idx = path.lastIndexOf(File.separator);
        fileName = path.substring(idx + 1);
    }

    public Long getSize() {
        return size;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public String getMessageId() {
        return messageId;
    }

    public void setMessageId(String messageId) {
        this.messageId = messageId;
    }

    //    private void register() {
//        if (CodecFactory.getInstance().getTransfer((short)2001) == null) {
//            CodecFactory.getInstance().register(TransferFile.class, (short)2001, new TransferFileCoder(), HandleType.local);
//        }
//    }
}
